import type {
  MeetingEnrollForm,
  MeetingEnrollQuery,
  MeetingEnrollVO,
} from './model';

import type { FileImportForm, ID, IDS, PageResult } from '#/api/common';

import { commonExport, ContentTypeEnum } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 分页查询会议报名列表
 * @param params
 * @returns 会议报名列表
 */
export function meetingEnrollPage(params?: MeetingEnrollQuery) {
  return requestClient.get<PageResult<MeetingEnrollVO>>(
    '/meeting/enroll/page',
    {
      params,
    },
  );
}

/**
 * 查询会议报名列表
 * @param params
 * @returns 会议报名列表
 */
export function meetingEnrollList(params?: MeetingEnrollQuery) {
  return requestClient.get<MeetingEnrollVO[]>('/meeting/enroll/list', {
    params,
  });
}

/**
 * 导出会议报名列表
 * @param params
 * @returns 会议报名列表
 */
export function meetingEnrollExport(params?: MeetingEnrollQuery) {
  return commonExport('/meeting/enroll/export', params ?? {});
}

/**
 * 查询会议报名详情
 * @param id id
 * @returns 会议报名详情
 */
export function meetingEnrollInfo(id: ID) {
  return requestClient.get<MeetingEnrollVO>(`/meeting/enroll/${id}`);
}

/**
 * 新增会议报名
 * @param data
 * @returns void
 */
export function meetingEnrollAdd(data: MeetingEnrollForm) {
  return requestClient.postWithMsg<void>('/meeting/enroll', data);
}

/**
 * 更新会议报名
 * @param data
 * @returns void
 */
export function meetingEnrollUpdate(data: MeetingEnrollForm) {
  return requestClient.putWithMsg<void>('/meeting/enroll', data);
}

/**
 * 删除会议报名
 * @param id id
 * @returns void
 */
export function meetingEnrollRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/meeting/enroll/${id}`);
}

/**
 * 导入报名数据
 * @param data
 * @param query
 * @returns void
 */
export function meetingEnrollImport(
  data: FileImportForm,
  query?: MeetingEnrollQuery,
) {
  return requestClient.postWithMsg<void>('/meeting/enroll/import', data, {
    headers: {
      'Content-Type': ContentTypeEnum.FORM_DATA,
    },
    isTransformResponse: false,
    params: query,
  });
}

/**
 * 下载报名导入模板
 * @returns blob
 */
export function meetingEnrollDownloadImportTemplate(
  params?: MeetingEnrollQuery,
) {
  return commonExport('/meeting/enroll/importTemplate', params ?? {});
}

/**
 * 按筛选条件添加报名人员到收藏夹
 * @param data
 */
export function meetingEnrollAddFavoriteBySearch(data: any) {
  return requestClient.postWithMsg<void>(
    `/meeting/enroll/addFavoriteBySearch`,
    data,
  );
}

/**
 * 设置会议报名人员角色
 * @param data
 */
export function meetingEnrollChangeRole(data: MeetingEnrollForm) {
  return requestClient.putWithMsg<void>('/meeting/enroll/changeRole', data);
}

/**
 * 设置会议报名人员审核状态
 * @param data
 */
export function meetingEnrollChangeAuditStatus(data: MeetingEnrollForm) {
  return requestClient.putWithMsg<void>(
    '/meeting/enroll/changeAuditStatus',
    data,
  );
}

/**
 * 设置会议报名人员签到状态
 * @param data
 */
export function meetingEnrollChangeSignStatus(data: MeetingEnrollForm) {
  return requestClient.putWithMsg<void>(
    `/meeting/enroll/changeSignStatus`,
    data,
  );
}
